﻿/*
 * Copyright (C) 2024-2025 Deepin Technology Co., Ltd.
 *
 * Author:     zhangbingyi <zhangbingyi@uniontech.com>
 *
 * Maintainer: zhangbingyi <zhangbingyi@uniontech.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#pragma once

#include "speedwidget.h"
#include "flowwidget.h"
#include "widgets/hswitchbutton.h"
//#include <DButtonBox>
//#include <DTipLabel>
//#include <DCommandLinkButton>
//#include <DBackgroundGroup>
//#include <DFrame>
//#include <DPushButton>
//#include <DSwitchButton>

#include <QPushButton>
#include <QLabel>
#include <QFrame>
#include <QCommandLinkButton>
#include <QItemDelegate>
#include <QStandardItemModel>
#include <QDialogButtonBox>

enum TabelType {
    AppsServices,
    Trafficranking,
};

class QVBoxLayout;
class QHBoxLayout;
class QLabel;
class QTableView;
class QPushButton;
class QStandardItemModel;
class QStandardItem;
class QComboBox;
class QToolButton;

namespace def {
class SystemSettings;
}


class DataUsageModel;
class DataUsageWidget : public QFrame
{
    Q_OBJECT
public:
    explicit DataUsageWidget(DataUsageModel *model = nullptr, QWidget *parent = nullptr);
    ~DataUsageWidget();

public Q_SLOTS:
    //切换按钮开关状态
    void slotChangeControlStatus(bool isChecked);

    // 当系统设置项改变时
    void onSysSettingChanged(const QString &key, const QVariant &value);

    void onButtonClicked(QAbstractButton*);
protected:
    void resizeEvent(QResizeEvent *event);
    bool eventFilter(QObject *obj, QEvent *event);

private:
    void initUI();
    void showAppsServices();
    void showTrafficranking();
    void settype(TabelType type);
    void refreshElideText(QPushButton* pBtn, const QString& strText);

private:
    DataUsageModel *m_model;
    SpeedWidget *m_speedwidget;
    FlowWidget *m_flowwidget;
    QVBoxLayout *m_layout; //最大布局
    QWidget *m_widget;
//    DBackgroundGroup *m_bgGroup;
    QDialogButtonBox *m_topSwitchWidgetBtn;
    bool m_tabeltype = 0;
    QVBoxLayout *m_tablelayout;
    QPushButton *btnSetting;
    QPushButton *btnUpdate;
    HSwitchButton *m_dataSwitchButton;
    SystemSettings *m_sysSettings; // 安全中心系统配置
    DBusInvokerInterface *m_monitorInterFaceServer; // 流量监控dbus类
};
